﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Mail;
using System.Web;

namespace EazyCMS.Web.tools
{
    /// <summary>
    /// GetItemData 的摘要说明
    /// </summary>
    public class GetItemData : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string zhuangtai = string.Empty;
            try
            {
                string xingming = context.Request["xingming"];
                string xingbie = context.Request["xingbie"];
                string lianxidianhua = context.Request["lianxidianhua"];
                string youzhengbianma = context.Request["youzhengbianma"];
                string lianxidizhi = context.Request["lianxidizhi"];
                string email = context.Request["email"];
                string zhuti = context.Request["zhuti"];
                string neirong = context.Request["neirong"];
                string shifougongkai = context.Request["shifougongkai"];
                string txtCode = context.Request["txtCode"];
                MailMessage mailMsg = new MailMessage();//两个类，别混了 引入System.Web这个Assembly
                mailMsg.IsBodyHtml = true;
                mailMsg.From = new MailAddress("1695506233@qq.com", "宜兴卓易科技");//源邮件地址 
                mailMsg.To.Add(new MailAddress("444964063@qq.com", "无"));//目的邮件地址。可以有多个收件人
                mailMsg.Subject = "校长邮箱";//发送邮件的标题 
                mailMsg.Body = "姓名：" + xingming +  "</br>email：" + email + "</br>主题：" + zhuti + "</br>内容：" + neirong  ;//发送邮件的内容 
                                                                                                            //mailMsg.Attachments.Add(new Attachment("c:/boot.ini"));//将附件附加到邮件消息对象中 ，可以有多个附件。

                ////创建一个发邮件的客户端
                SmtpClient client = new SmtpClient("smtp.qq.com", 587);//smtp服务器地址。不要拿qq发也填这个
                client.EnableSsl = true;

                client.Credentials = new NetworkCredential("1695506233@qq.com", "eazytec123");//这里的用户名一般要和From的邮箱一致
                client.Send(mailMsg);
                zhuangtai = "1";
            }
            catch (Exception)
            {

                zhuangtai = "0";
            }
            context.Response.Write(zhuangtai);
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}